package fzu.functiongather.MainPage;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.Window;

import java.util.ArrayList;
import java.util.List;

import fzu.functiongather.R;
import fzu.functiongather.mUtils.ViewPagerIndicator;
import fzu.functiongather.mUtils.myPager;

/**
 * Created by WLT on 2016/7/12.
 */
public class PageActivity extends FragmentActivity implements View.OnClickListener {
    private ViewPager mViewPager;
    private ViewPagerIndicator mIndicator;
    private List<Fragment> list = new ArrayList<Fragment>();
    private FragmentPagerAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.mainpage_main);
        initViews();
        initDatas();
        myPager myPager =new myPager(mViewPager,mIndicator,list,mAdapter);
    }

    //初始化Views
    private void initViews(){
        mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
        mIndicator = (ViewPagerIndicator) findViewById(R.id.id_indicator);
    }
    //初始化数据
    private void initDatas() {
        Fragment_Page1 page1 = new Fragment_Page1();
        Fragment_Page2 page2 = new Fragment_Page2();
        Fragment_Page3 page3 = new Fragment_Page3();
        Fragment_Page4 page4 = new Fragment_Page4();
        list.add(page1);
        list.add(page2);
        list.add(page3);
        list.add(page4);
        mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return list.get(position);
            }
            @Override
            public int getCount() {
                return list.size();
            }
        };
    }

    @Override
    public void onClick(View v) {

    }
}
